<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8"/>
    <title>添加</title>
    <link href="__STATIC__/component/pear/css/pear.css" rel="stylesheet"/>
    {include file='public/head.html'}
</head>
<body class="childrenBody {:dialog_css()}">

<form class="layui-form" action="{:url('add')}" method="post">

    <div class="layui-form-item">
        <label class="layui-form-label layui-form-item-required">模型名称</label>
        <div class="layui-input-block">
            <input type="text" name="title" lay-verify="required" placeholder="模型名称" value="测试" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label layui-form-item-required">表名(标识)</label>
        <div class="layui-input-block">
            <input type="text" name="table_name" lay-verify="required" placeholder="表名(不包含前缀)" value="test" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label layui-form-item-required">表注释</label>
        <div class="layui-input-block">
            <input type="text" name="table_comment" lay-verify="required" placeholder="表注释" value="测试表" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label layui-form-item-required">表主键</label>
        <div class="layui-input-block">
            <input type="text" name="table_primary" value="id" placeholder="表主键，多个用,分割" class="layui-input"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label layui-form-item-required">存储引擎</label>
        <div class="layui-input-block">
            <input type="radio" name="table_engine" value="InnoDB" title="InnoDB" checked>
            <input type="radio" name="table_engine" value="MyISAM" title="MyISAM">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">字符集</label>
        <div class="layui-input-block">
            <input type="text" name="table_charset" placeholder="字符集" value="utf8mb4" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">排序规则</label>
        <div class="layui-input-block">
            <input type="text" name="table_collate"  placeholder="排序规则" value="utf8mb4_general_ci" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <label class="layui-form-label">回收站</label>
        <div class="layui-input-block">
            <input type="hidden" name="is_recycle" value="0">
            <input type="checkbox" name="is_recycle" value="1" lay-skin="switch" lay-text="开启|关闭" />
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">预设字段</label>
        <div class="layui-input-block">
            {:form_select('field_ids', widget('field')->get(), '1,2,10,15,16,19', ' xm-select="field" xm-select-skin="normal"')}
        </div>
    </div>

    <div class="layui-form-item layer-footer">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit="" lay-filter="save">
                <i class="layui-icon layui-icon-ok"></i>
                添加
            </button>
            <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>

<script src="__STATIC__/component/layui/layui.js"></script>
<script src="__STATIC__/component/pear/pear.js"></script>
<script>
    layui.use(['aphp', 'form', 'select'], function () {
        var aphp = layui.aphp,
            select = layui.select,
            form = layui.form;

        form.on('submit(save)', function (data) {
            aphp.request.postForm(data, 0, function () {
                parent.layer.close(parent.layer.getFrameIndex(window.name));
                parent.layui.table.reload('currentTable');
            });
            return false;
        });
    })
</script>
</body>
</html>